﻿<UserControl x:Class="WpfPersianDatePicker.Views.PCalendar"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             FlowDirection="RightToLeft"
             FontFamily="Tahoma" FontSize="11"               
             xmlns:conv="clr-namespace:WpfPersianDatePicker.Converters"              
             d:DesignHeight="600" d:DesignWidth="800">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Themes/Styles.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <conv:ToPersianNumberConverter x:Key="ConvToPersianNumberConverter" />
        </ResourceDictionary>      
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="{StaticResource MainBackground}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="170" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                BorderThickness="1" CornerRadius="5" 
                BorderBrush="{StaticResource HeaderBorderBrush}"
                Background="{StaticResource HeaderBorderBackground}"
                Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="4"
                                Height="27" Margin="1">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="28" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="28" />
                </Grid.ColumnDefinitions>

                <TextBlock
                    Grid.Column="0"
                    VerticalAlignment="Center"
                    HorizontalAlignment="Center">
                        <Hyperlink Command="{Binding ClickPrev}">
                            <ToolTipService.ToolTip>
                                <TextBlock Text="قبلي" FontFamily="Tahoma" 
                                       VerticalAlignment="Center"
                                       FontSize="11" Margin="2" />
                            </ToolTipService.ToolTip>                                        
                                <Path 
                                    Data="M0,0.5 L1,1 1,0Z" Width="10" Height="8"
                                    Stretch="Fill" Fill="{StaticResource PrevNextFillColor}" />                    
                        </Hyperlink>
                </TextBlock>

                <TextBlock Grid.Column="1"      
                           VerticalAlignment="Center"
                           HorizontalAlignment="Center">
                        <Hyperlink                    
                            Foreground="{StaticResource HeaderHyperlinkButtonForeground}"
                            Command="{Binding TitleClick}">
                                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" 
                                               FontSize="11" Foreground="{StaticResource HeaderHyperlinkButtonForeground}"
                                               FontWeight="Bold"                                       
                                               Text="{Binding CalendarGUIData.HeaderText, 
                                                              Converter={StaticResource ConvToPersianNumberConverter}}"  />
                        </Hyperlink>
                </TextBlock>

                <TextBlock    
                    Grid.Column="2"
                    VerticalAlignment="Center"
                    HorizontalAlignment="Center">
                            <Hyperlink Command="{Binding ClickNext}">
                                    <Path 
                                        Data="M0,0 L1,0.5 0,1Z" Width="10" Height="8"
                                        Stretch="Fill" Fill="{StaticResource PrevNextFillColor}" />
                                <ToolTipService.ToolTip>
                                    <TextBlock Text="بعدي" FontFamily="Tahoma" 
                                           VerticalAlignment="Center"
                                           FontSize="11" Margin="2" />
                                </ToolTipService.ToolTip>
                            </Hyperlink>
                </TextBlock>
            </Grid>
        </Border>

        <ItemsControl ItemsSource="{Binding DaysInfo}"
                      Name="MainItemsControl"
                      VerticalAlignment="Top"     
                      HorizontalAlignment="Center"
                      Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="4">            
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <UniformGrid
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Columns="{Binding CalendarGUIData.UniformGridColumns}" 
                        Rows="{Binding CalendarGUIData.UniformGridRows}">
                    </UniformGrid>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <ContentControl>
                        <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                                BorderThickness="1" CornerRadius="3" BorderBrush="{Binding BorderBrush}"
                                Background="{Binding BackgroundBrush}"                                
                                Width="{Binding CellWidth}" Height="{Binding CellHeight}" Margin="1">
                            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">
                                <Hyperlink                                
                                    FontSize="11" Foreground="{Binding Foreground}"
                                    FontWeight="{Binding FontWeight}"                   
                                    IsEnabled="{Binding HyperlinkIsEnabled}"
                                    TextDecorations="{x:Null}"
                                    Command="{Binding DataContext.DayClick, ElementName=LayoutRoot}"                                    
                                    CommandParameter="{Binding Number}">                                    
                                    <TextBlock                                         
                                        HorizontalAlignment="Center" VerticalAlignment="Center" 
                                        Text="{Binding Number, Converter={StaticResource ConvToPersianNumberConverter}}" />
                                </Hyperlink>
                            </TextBlock>
                        </Border>
                    </ContentControl>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>

        <StackPanel 
            Grid.Row="2" 
            Margin="0"
            Name="TodayRoot"
            Grid.ColumnSpan="4"
            Background="{StaticResource FooterStackPanelBackground}"
            HorizontalAlignment="Stretch">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                <TextBlock HorizontalAlignment="Center">
                        <Hyperlink
                                Command="{Binding ShowTodayClick}">
                                <TextBlock Foreground="{StaticResource FooterForeground}"
                                        HorizontalAlignment="Center"
                                        Text="امروز " FontWeight="Bold" />
                        </Hyperlink>
                </TextBlock>
                <TextBlock 
                    HorizontalAlignment="Center"                
                    Text="{Binding CalendarGUIData.Today, 
                    Converter={StaticResource ConvToPersianNumberConverter}}" 
                        FontWeight="Bold" Foreground="{StaticResource FooterForeground}" />
            </StackPanel>
        </StackPanel>
    </Grid>
</UserControl>
